<?php if (count($offerList)) : ?>

<div class="indx clearfix">
    <?php echo include_component('home', 'leftPanel', array('noResults' => $noResults, 'numResults' => $numResults)); ?>
  <div class="accordion_set right">
    
  <?php if ($noResults) : ?>
  <div class="clear error_box radius" style="padding: 8px;">
    <p>No exact matches found to match your criteria, but we also found...</p>
  </div>
  <?php endif; ?>
  <?php if ($numResults) : ?>
  <div class="clear sucess_box radius" style="padding: 8px;">
    <p><?php echo $numResults; ?> offer<?php if ($numResults>1) : ?>s<?php endif; ?> found to match your search criteria...</p>
  </div>
  <?php endif; ?>
    <div id="accordion">
      <ul class=""  id="acco_set">
        <?php $i = 0; ?>
          <?php foreach ($offerList as $offer) : ?>
            <?php $movie = $offer->getMOVIE(); ?>
            <?php $cinema = $offer->getCINEMA(); ?>
            <?php $merchant = $cinema->getMERCHANT(); ?>
            <?php
            $shareUrl = sfContext::getInstance()->getController()->genUrl('@home', true);
            $shareTitle = 'Supertain | ' . $movie->getTitle() . ' - ' . $cinema->getName() . ' - ' . $offer->getMerchantsSessionTime('M d, H:i') . ' - ' . $offer->getTicketPriceFormatted();
            $shareImage = ServerUtil::getServerUrl() . '/uploads/posters/' . $movie->getUrlPoster();
            $shareSummary = 'Supertain | ' . $movie->getTitle() . ' - ' . $cinema->getName() . ' - ' . $offer->getMerchantsSessionTime('M d, H:i') . ' - ' . $offer->getTicketPriceFormatted();
            $shareAttributes = 'st_url="' . $shareUrl . '" st_title="' . $shareTitle . '" st_image="' . $shareImage . '" st_summary="' . $shareSummary . '"';
            ?>
        
        <li class="acc_box">
              <?php
              $timeLeft = StringUtil::getTimeElapsed(strtotime($offer->getSessionTime()));
              $chunks = explode(' ', $timeLeft);
              $digit = $chunks[0];
              $measurement = $chunks[1];
              ?>
              <?php if ($offer->getSeatsAvailableCount() < 6 && $offer->getSeatsAvailableCount() > 0) : ?>
                <span class="ticket_item"><?php echo $offer->getSeatsAvailableCount(); ?> ticket<?php if ($offer->getSeatsAvailableCount() > 1):?>s<?php endif;?> left!</span>
              <?php elseif ($offer->getSeatsAvailableCount() == 0) : ?>
                <span class="ticket_item">Sold Out!</span>
              <?php elseif ($digit < 60 && ($measurement == 'minutes' || $measurement == 'minute')) : ?>
                <span class="ticket_item"><?php echo $digit; ?> min<?php if ($digit > 1):?>s<?php endif;?> left!</span>
              <?php endif; ?>
              <form id="offer_<?php echo $i; ?>" action="<?php echo SystemUtil::generatePurchaseLink($offer, $movie); ?>" method="POST">  
              <div class=" clearfix acc_head">
                <div class="poster_info">
                  
                  <div class="posterdetail">
                    <div class="special"><?php echo ($offer->getAdditionalInfo()) ? strtoupper($offer->getAdditionalInfo()) : '&nbsp;'; ?></div>
                    <div class="clearfix">
                      <div class="left"> <?php if (file_exists(sfConfig::get('sf_upload_dir') . '/logos/' . $cinema->getId() . '.jpg')) : ?><img alt="<?php echo $cinema->getName(); ?>" title="<?php echo $cinema->getName(); ?>" src="/uploads/logos/<?php echo $cinema->getId(); ?>.jpg" width="30" height="30" class="left" /><?php else: ?><span style="width: 30px; padding-right:8px; padding-top: 8px;" class="left">&nbsp;</span><?php endif; ?> <span class="left vila"><p><?php echo $cinema->getName(); ?></p><p style="font-size:10px;"><?php echo '+' . ceil($offer['DISTANCE']) . 'km'; ?></p></span>
                        <label class="left" style="cursor: pointer;"><?php echo StringUtil::shortText($movie->getTitle(), 40); ?> <?php if (strtolower($movie->getRating()) != 'unrated') : ?><span style="font-size:11px;">[<?php echo $movie->getRating(); ?>]</span><?php endif; ?><p><?php echo $offer->getMerchantsSessionTime('M d, h:iA'); ?></p></label>
                      </div>
                      <div class="right">
                        <div class="left dateset">
                          
                          <?php if ($offer->getSeatsAvailableCount() > 0) : ?>
                          <p class="" style="font-size:10px;">Qty</p>
                          <select name="quantity" class="quantity_box">
                            <?php for ($x=1; $x<=15; $x++) : ?>
                            <?php if ($offer->getSeatsAvailableCount() >= $x) : ?>
                            <option value="<?php echo $x; ?>"><?php echo $x; ?></option>
                            <?php endif; ?>
                            <?php endfor; ?>
                          </select>
                          <?php endif; ?>


                        </div>
                        <?php
                        $price = $offer->getTicketPriceFormatted();
                        $exp = explode('.', $price);
                        ?>
                        <div class="left">
                          <h4 class="left"><?php echo $exp[0]; ?><span class="sm">.<?php echo $exp[1]; ?></span></h4>
                        </div>
                        <div class="right">
                          <?php if ($offer->getSeatsAvailableCount() > 0) : ?><a class="buynow" href="javascript:void(0);" rel="<?php echo $i; ?>">Buy Now</a><?php endif; ?>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
               



              <!--  Showing Accordnt-->
              <div class=" clearfix acc_body" id="mainwrp"<?php if ($i) : ?> style="display: none;"<?php endif; ?>>
                <div class=" clearfix">
                  <div class="poster left"> <?php if ($movie->getUrlPoster()) : ?><img src="/uploads/posters/<?php echo $movie->getUrlPoster(); ?>" width="<?php echo sfConfig::get('app_movie_poster_width'); ?>" alt="<?php echo $movie->getTitle(); ?>" title="<?php echo $movie->getTitle(); ?>" /><?php endif; ?> </div>
                  <div class="poster_info right">
                    <div class="clear mb22 text_con">
                      <p class="left"><?php echo $movie->getSynopsis(); ?></p>
                    </div>
                  </div>
                </div>

                <div class=" clearfix">
                  <div class="clearfix social_mdi"> 
                    <span class="st_facebook" <?php echo $shareAttributes; ?>></span>
                    <span class="st_twitter" <?php echo $shareAttributes; ?>></span>
                    <span class="st_email" <?php echo $shareAttributes; ?>></span>
                  </div>
                  <div class=" clearfix btnlink"> <?php if ($movie->getUrlTrailer()) : ?><a href="<?php echo $movie->getUrlTrailer(); ?>" target="_blank" class="radius wt">Watch Trailer</a><?php endif; ?> <a href="<?php echo $movie->getUrlImdb(); ?>" target="_blank" class="radius im">IMDB</a> <a href="<?php echo $movie->getUrlRt(); ?>" target="_blank" class="radius ro">Rotten Tomatoes</a> <a href="<?php echo $cinema->getUrlGmap(); ?>" target="_blank" class="radius map">Map</a> </div>
                </div>
              </div>
              </form>
              <!--  Showing Accordnt end-->
            </li>
          
          
       
        <?php $i++; ?>
          <?php endforeach; ?>
      </ul>
    </div>
  </div>
</div>

<?php else : ?>

<div id="container">
  <div class="content_wrp">
    <div class=" clear container">
      <div class="errorbox" >
        <div class="confirmbox">
          <div class="titlbox clearfix"> <em>ss</em>
            <h2>Sorry, currently we got no active offers!</h2>
          </div>
          <div class="contbox">
            <p>Please visit us again in few hours.</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<?php endif; ?>